@extends('app')
@section('content')
    <div class="jumbotron">
        <div class="container">
            <div class="media">
                <div class="media-left">
                    <a href="#">
                        <img src="{{ $discussion->user->avater }}" alt="64x64" class="media-object img-circle" style="width:64px;height:64px;">
                    </a>
                </div>
                <div class="media-body">
                    <h4 class="media-heading">{{ $discussion->title }}
                        @if(Auth::check() && Auth::user()->id == $discussion->user_id)
                        <a class="btn btn-primary btn-lg pull-right" href="/discussions/{{$discussion->id}}/edit" role="button">修改帖子</a></h4>
                        @endif
                    {{ $discussion->user->name }}
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-md-9" role="main">
                <div class="blog-post">
                    {{--之前的老方法--}}
                    {{--{{ $discussion->body }}--}}
                    {{--添加markdown解析后的方法--}}
                    {!! $html !!}
                </div>
                <hr>
                @foreach($discussion->comments as $comment)
                    <div class="media">
                        <div class="media-left">
                            <a href="#">
                                <img class="media-object img-circle" alt="64x64"  src="{{ $comment->user->avater }}" style="width: 64px;height: 64px;">
                            </a>
                        </div>
                        <div class="media-body">
                            <h4 class="media-heading">{{ $comment->user->name }}</h4>
                            {{ $comment->body }}
                        </div>
                    </div>
                @endforeach
                <hr>
                @if(Auth::check())
                    {!! Form::open(['url'=>'/comment']) !!}
                    {!! Form::hidden('discussion_id',$discussion->id) !!}
                        <div class="form-group">
                            {{--{!! Form::label('body','内容:') !!}--}}
                            {!! Form::textarea('body',null,['class'=>'form-control']) !!}
                        </div>
                        <div>
                            {!! Form::submit('发表评论',['class'=>'btn btn-success pull-right']) !!}
                        </div>
                    {!! Form::close() !!}
                @else
                    <a href="/user/login" class="btn btn-block btn-success"></a>
                @endif
            </div>
        </div>
    </div>
@stop